import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import sun.jdbc.odbc.JdbcOdbcDriver;

public class test {
	public static void main(String arg[]) {
		String username = "sa";
		String password = null;
		String sql = null;
		ResultSet rs = null;
		try {
			DriverManager.registerDriver(new JdbcOdbcDriver());
			// IP21DataSource
			String url = "jdbc:odbc:IP21DataSource";
			Connection con = DriverManager.getConnection(url, username,
					password);
			Statement st = con.createStatement();
			sql = "Select IP_TREND_VALUE,IP_TREND_TIME from \"11MI09_FLOW_MEAS\" where IP_TREND_TIME in (select MIN(IP_TREND_TIME) from \"11MI09_FLOW_MEAS\" where IP_TREND_TIME>'31-MAY-11 08:00:00')";
			System.out.println(sql);
			rs = st.executeQuery(sql);
			while (rs.next()) {
				System.out.println(rs.getString(1) + " "
						+ rs.getString(2));
			}
			rs.close();
			st.close();
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
